<template>
    <el-card shadow="never" style="max-height: 700px; overflow: auto">
        <el-form ref="form" :model="form" :rules="rules" label-width="90px" :disabled="disabled">
            <el-form-item label="id:" prop="id" v-show="false">
                <el-input v-model="form.id" disabled />
            </el-form-item>

            <el-form-item label="反馈详情">
                <el-cascader
                    v-model="form.one_kfs"
                    :options="options"
                    :props="props"
                    clearable>
                </el-cascader>
            </el-form-item>

            <el-form-item label="邮件内容:" prop="email_detail">
                <el-input type="textarea" v-model="form.email_detail" placeholder="请输入邮件内容" clearable />
            </el-form-item>

            <el-form-item>
                <el-button type="primary" @click="submitForm">确认 </el-button>
                <el-button type="warning" @click="cancel">取消 </el-button>
            </el-form-item>
        </el-form>
    </el-card>
</template>

<script>
export default {
    name: 'EditForm',
    props: {
        findFormData: {
            type: Object,
            default: {},
        },
        editFormParams: {
            type: Object,
            default: {},
        },
        // 表单是否禁用
        disabled: {
            type: Boolean,
            default: false,
        },
    },
    data() {
        return {
            questiontype: [],
            questiondetail: {},
            questiondetail2: {},
            typeOptions: [],
            // 编辑表单验证规则
            rules: {},
            form: {},
            props: { multiple: true },
            options:[],
        }
    },
    watch: {
        findFormData: {
            handler(nval) {
                if (JSON.stringify(nval) != '{}') {
                    this.$nextTick(() => {
                        this.form = nval
                        this.options = nval.options
                    })
                }
                this.form.one_kfs = nval.optionsid
                console.log('one_kfs',this.form.one_kfs);
            },
            immediate: true,
            deep: false,
        },
    },
    methods: {
        // 取消按钮
        cancel() {
            this.$emit('editFormCancel')
        },

        submitForm() {
            this.$refs['form'].validate((valid, obj) => {
                if (valid) {
                    this.$emit('submitForm', this.form)
                }
            })
        },

        // 表单重置
        reset() {
            this.resetForm('form')
        },
    },
}
</script>
